#pragma once

#include <set>
#include "Telegram.h"
#include "Singleton.h"

class BasePlayer;

/*
	Telegram Dispatcher.
	Telegram's Manager, discharge incoming telegrams is its duty.
	If delayed Telegrams are allowed, remember to call DispatchQueuedMessages() in your main loop.
*/

class TelegramDispatcher : public Singleton<TelegramDispatcher>
{

public:
	void DispatchTelegram(int sender, int receiver, int msg, float delayTime = 0.f, const void* param = 0);

private:
	std::set<Telegram> PriorityQueue;
	void Discharge(BasePlayer* receiver, Telegram telegram);
	void DispatchQueuedMessages();

};
#define MsgDispatcher TelegramDispatcher::Istance()


